// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Spike Logs Object
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 54 : TYPE_SPIKELOGS

// Function declarations
reserve function SpikeLogs_DebugDraw
reserve function SpikeLogs_DebugSpawn

// Static Values

// Tables

function SpikeLogs_DebugDraw
	DrawSprite(0)
end function


function SpikeLogs_DebugSpawn
	CreateTempObject(TypeName[Spike Logs], 0, object.xpos, object.ypos)
end function


event ObjectMain
	object.value1 = GHZSetup_value29
	object.value1 >>= 1
	object.value1 &= 7
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		checkResult = 0
		switch object.value1
		case 0
			BoxCollisionTest(C_TOUCH, object.entityPos, -2, -16, 2, 0, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			break
		case 1
			BoxCollisionTest(C_TOUCH, object.entityPos, 14, -16, 18, 0, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			break
		case 2
			BoxCollisionTest(C_TOUCH, object.entityPos, 30, -16, 34, 0, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			break
		case 3
			BoxCollisionTest(C_TOUCH, object.entityPos, 46, -16, 50, 0, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			break
		case 4
			BoxCollisionTest(C_TOUCH, object.entityPos, 62, -16, 66, 0, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			break
		case 5
			BoxCollisionTest(C_TOUCH, object.entityPos, 78, -16, 82, 0, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			break
		case 6
			BoxCollisionTest(C_TOUCH, object.entityPos, 94, -16, 98, 0, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			break
		case 7
			BoxCollisionTest(C_TOUCH, object.entityPos, 110, -16, 114, 0, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			break
		end switch
		if checkResult == 1
			CallFunction(PlayerObject_Hit)
		end if
	next
end event


event ObjectDraw
	temp0 = 16
	temp0 -= GHZSetup_value29
	temp0 >>= 1
	temp1 = object.xpos
	DrawSpriteXY(temp0, temp1, object.ypos)
	temp0++
	temp1 += 0x100000
	DrawSpriteXY(temp0, temp1, object.ypos)
	temp0++
	temp1 += 0x100000
	DrawSpriteXY(temp0, temp1, object.ypos)
	temp0++
	temp1 += 0x100000
	DrawSpriteXY(temp0, temp1, object.ypos)
	temp0++
	temp1 += 0x100000
	DrawSpriteXY(temp0, temp1, object.ypos)
	temp0++
	temp1 += 0x100000
	DrawSpriteXY(temp0, temp1, object.ypos)
	temp0++
	temp1 += 0x100000
	DrawSpriteXY(temp0, temp1, object.ypos)
	temp0++
	temp1 += 0x100000
	DrawSpriteXY(temp0, temp1, object.ypos)
end event


event ObjectStartup
	LoadSpriteSheet("GHZ/Objects.gif")
	SpriteFrame(-8, -8, 16, 16, 167, 1)
	SpriteFrame(-8, -8, 16, 19, 115, 18)
	SpriteFrame(-8, -8, 16, 24, 132, 18)
	SpriteFrame(-8, -8, 16, 20, 149, 18)
	SpriteFrame(-8, -8, 0, 0, 149, 18)
	SpriteFrame(-8, -24, 16, 30, 166, 18)
	SpriteFrame(-8, -24, 16, 30, 115, 38)
	SpriteFrame(-8, -24, 16, 30, 132, 43)
	SpriteFrame(-8, -8, 16, 16, 167, 1)
	SpriteFrame(-8, -8, 16, 19, 115, 18)
	SpriteFrame(-8, -8, 16, 24, 132, 18)
	SpriteFrame(-8, -8, 16, 20, 149, 18)
	SpriteFrame(-8, -8, 0, 0, 149, 18)
	SpriteFrame(-8, -24, 16, 30, 166, 18)
	SpriteFrame(-8, -24, 16, 30, 115, 38)
	SpriteFrame(-8, -24, 16, 30, 132, 43)
	SetTableValue(TypeName[Spike Logs], DebugMode_ObjCount, DebugMode_TypesTable)
	SetTableValue(SpikeLogs_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(SpikeLogs_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
